/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package multiface.awwadco.jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego64
 */
@Entity
@Table(name = "news")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "News.findAll", query = "SELECT n FROM News n"),
    @NamedQuery(name = "News.findByIdnews", query = "SELECT n FROM News n WHERE n.idnews = :idnews"),
    @NamedQuery(name = "News.findByTitolo", query = "SELECT n FROM News n WHERE n.titolo = :titolo"),
    @NamedQuery(name = "News.findByDataora", query = "SELECT n FROM News n WHERE n.dataora = :dataora")})
public class News implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idnews")
    private Integer idnews;
    @Basic(optional = false)
    @Column(name = "titolo")
    private String titolo;
    @Basic(optional = false)
    @Lob
    @Column(name = "testo")
    private String testo;
    @Basic(optional = false)
    @Column(name = "dataora")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataora;
    @JoinColumn(name = "utente_idutente", referencedColumnName = "idutente")
    @ManyToOne(optional = false)
    private Utente utenteIdutente;
    @JoinColumn(name = "prodotto", referencedColumnName = "idprodotto")
    @ManyToOne
    private Prodotto prodotto;

    public News() {
    }

    public News(Integer idnews) {
        this.idnews = idnews;
    }

    public News(Integer idnews, String titolo, String testo, Date dataora) {
        this.idnews = idnews;
        this.titolo = titolo;
        this.testo = testo;
        this.dataora = dataora;
    }

    public Integer getIdnews() {
        return idnews;
    }

    public void setIdnews(Integer idnews) {
        this.idnews = idnews;
    }

    public String getTitolo() {
        return titolo;
    }

    public void setTitolo(String titolo) {
        this.titolo = titolo;
    }

    public String getTesto() {
        return testo;
    }

    public void setTesto(String testo) {
        this.testo = testo;
    }

    public Date getDataora() {
        return dataora;
    }

    public void setDataora(Date dataora) {
        this.dataora = dataora;
    }

    public Utente getUtenteIdutente() {
        return utenteIdutente;
    }

    public void setUtenteIdutente(Utente utenteIdutente) {
        this.utenteIdutente = utenteIdutente;
    }

    public Prodotto getProdotto() {
        return prodotto;
    }

    public void setProdotto(Prodotto prodotto) {
        this.prodotto = prodotto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idnews != null ? idnews.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof News)) {
            return false;
        }
        News other = (News) object;
        if ((this.idnews == null && other.idnews != null) || (this.idnews != null && !this.idnews.equals(other.idnews))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "multiface.awwadco.jpa.News[ idnews=" + idnews + " ]";
    }
    
}
